package com.zzz.robot201.mvp.ui.adapter;

import android.opengl.Visibility;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.zzz.robot201.R;
import com.zzz.robot201.mvp.model.api.bean.MsgBean;

import java.util.Arrays;
import java.util.List;


public class MsgAdapter extends BaseQuickAdapter<MsgBean.DataBean.ListBean, BaseViewHolder> {

    public MsgAdapter() {
        super(R.layout.item_msg);
    }

    @Override
    protected void convert(BaseViewHolder helper, MsgBean.DataBean.ListBean item) {

        if (helper.getLayoutPosition() == 0) {
            helper.setVisible(R.id.iv_read, false);
            helper.setBackgroundRes(R.id.ll_item_msg, R.drawable.ic_select);
        } else {
            if (item.getReadStatus() == 1) {
                helper.setVisible(R.id.iv_read, false);
            }else {
                helper.setVisible(R.id.iv_read, true);
            }
        }
        helper.setText(R.id.tv_msg_tittle, item.getMsgTitle());
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (OnItemClickListener != null)
                    OnItemClickListener.onItemClick(item.getId(), helper.getLayoutPosition());
            }
        });
    }

    private OnItemClickListener OnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener OnItemClickListener) {
        this.OnItemClickListener = OnItemClickListener;
    }

    public interface OnItemClickListener {
        void onItemClick(int momentId, int position);
    }
}
